#ifndef TCPCLIENTMANAGER_H
#define TCPCLIENTMANAGER_H

#include <QObject>
#include <QTcpSocket>
#include <QList>

class TcpClientManager : public QObject
{
    Q_OBJECT
public:
    explicit TcpClientManager(QObject *parent = 0);

    void setTcpClient(QTcpSocket *_tcpClient);

    QTcpSocket *getTcpClient();
    bool valid();
    void processIncommingData(const QByteArray &buffer);

signals:
    void receivedMessage(QByteArray);
public slots:
    void startRead();
    void sendData(QByteArray);
    void clientDisconnect();
    void clientDestroyed();

private:
    QTcpSocket *_tcpClient;
    QByteArray _buffer;
    bool _hasStx;
    bool _hasEtx;
};

typedef QList<TcpClientManager> TcpClientManagers;
typedef QListIterator<TcpClientManager> TcpClientManagersIterator;
typedef QList<TcpClientManager*> TcpClientManagers_ptr;
typedef QListIterator<TcpClientManager*> TcpClientManagersIterator_ptr;

#endif // TCPCLIENTMANAGER_H
